package com.itheima.controller;

import com.itheima.pojo.Article;
import com.itheima.pojo.Result;
import com.itheima.service.HomePageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/homepage")
public class HomePageController {
	@Autowired
	private HomePageService homePageService;

	//	查询所有文章
	@GetMapping("/homepage")
	public Result<List<Article>> lists(String kw) {
		List<Article> article = homePageService.lists(kw);
		return Result.success(article);
	}

	//	根据id查询单个文章
	@GetMapping("/homepage/ArticleDetails")
	public Result<List<Article>> lists(Integer id) {
		List<Article> article = homePageService.findById(id);
		return Result.success(article);
	}

	//	点赞
	@PutMapping("/homepage/ArticleDetails")
	public Result findlike() {
		homePageService.findlike();
		return Result.success();
	}


}
